using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ebookreader.Resources;

namespace ebookreader
{
    public class MenuReadPopup : PopUp
    {
        #region Fields
        Reader reader;        
        #endregion
        State currentState;
        public MenuReadPopup(Game game, Reader reader)
            : base(game)
        {            
            sprite_batch = Game.Services.GetService(typeof(SpriteBatch)) as SpriteBatch;
            this.reader = reader;
        }

        public override void Initialize()
        {
            //input_manager = Game.Services.GetService(typeof(IInputManager)) as IInputManager;
            currentState = Game.Services.GetService(typeof(State)) as State;
            input_manager.OnTap += new InputManager.Tap(OnTap);
            input_manager.onBackButtonPressed += new InputManager.Back(() => { this.Dispose(); });
            base.Initialize();
        }

        public override void Draw(GameTime gameTime)
        {
            sprite_batch.Begin();
            sprite_batch.Draw(popup_back, GraphicsDevice.Viewport.Bounds, Color.White);
            sprite_batch.Draw(popup_read_body, new Vector2(190, 80), Color.White);
            sprite_batch.End();
            base.Draw(gameTime);
        }

        Texture2D popup_read_body, back, popup_back, button_ring;
        SpriteFont font;
        protected override void LoadContent()
        {
            popup_read_body = Game.Content.Load<Texture2D>("Definitivo/popup_read_body");
            popup_back = Game.Content.Load<Texture2D>("todo/idle");
            button_ring = Game.Content.Load<Texture2D>("Definitivo/button_ring");
            back = Game.Content.Load<Texture2D>("Definitivo/black_back");
            
            font = Game.Content.Load<SpriteFont>("Fonts/menu_piccolo");

            var conti = new BoxedLabelButton(sprite_batch, button_ring, new Vector2(319, 142), font, Lang.MM_Continue, Color.Black, true, currentState.options);
            conti.OnPress += new Press(
                (me) => {this.Dispose(); }
                );
            entries.Add(conti);

            var gotopage = new BoxedLabelButton(sprite_batch, button_ring, new Vector2(319, 197), font, Lang.Go_to_page, Color.Black, true, currentState.options);
            gotopage.OnPress += new Press((me) =>
            {
                //this.Dispose();
                Game.Components.Add(new PageSelPopUp(Game,reader,this));
            });
            entries.Add(gotopage);

            var bookmark = new BoxedLabelButton(sprite_batch, button_ring, new Vector2(319, 252), font, Lang.Bookmark, Color.Black, true, currentState.options);
            bookmark.OnPress += new Press((me) =>
                {
                    //this.Dispose();
                    Game.Components.Add(new BookmarkSelPopUp(Game, reader, this));
                });
            entries.Add(bookmark);

            var exit = new BoxedLabelButton(sprite_batch, button_ring, new Vector2(319, 308), font, Lang.MM_Exit, Color.Black, true, currentState.options);
            exit.OnPress += new Press((me) => ScreenManager.SelectMainMenu(Game));
            entries.Add(exit);




            //var mess = new LabelButton(sprite_batch, font, new Vector2(400-font.MeasureString(message).X/2, 110), Color.White, message);
            //entries.Add(mess);

            //var confirm = new LabelButton(sprite_batch, font, new Vector2(450, 300), Color.Green, "Confirm");
            //confirm.OnPress += new Press((me)=>{ onConfirm(); this.Dispose();});

            //entries.Add(confirm);
            var back_button = new TextureButton(sprite_batch, back, new Vector2(210, 100), currentState.options);
            back_button.OnPress += new Press(
                (me) => 
                {
                    this.Dispose(); 
                }
                );
            entries.Add(back_button);


            base.LoadContent();
        }



    }
}
